function h=drawimage(img,pos)
% drawimage: Draw an specified image object at specified position
%
% SYNTAX:
%   h = drawimage(img,pos)
%   Return handles of graphics objects representing the image object.
%   Image object img should be created with function NEWIMAGE.

%   Author: Hongbin Ma
%   Last updated: 2009-6-1 with MATLAB 6.5
%   Problems or suggestions? Email me: mathmhb[at]163.com

ax=axis;
if nargin==1,
    pos=[0,0];
end;
if isempty(get(gca,'Children')),
    h=plot([ax(1),ax(2)],[ax(3),ax(4)]);
    set(h,'Visible','off');
    hold on;
end;
x=img.x*img.sx*img.size/100*(ax(2)-ax(1))+pos(1);
y=img.y*img.sy*img.size/100*(ax(4)-ax(3))+pos(2);
h=image(x,y,img.c);
set(gca,'YDir','normal');